Page({

  /**
   * 页面的初始数据
   */
  data: {
    redPacket: '改为拼手气红包',
    packet:'当前为普通红包,',
    type:'普通红包',
    price:'单个金额',
    userPrice:'',
    userNum:'',
    isPrice:false,
    isNum:false,
    isActive:false
  },
  swichNav:function(){
    if (this.data.type == '普通红包'){
      this.setData({
        redPacket: '改为普通红包',
        packet: '当前为拼手气红红包,',
        type: '随机红包',
        price: '总金额'
      })
    }else{
      this.setData({
        redPacket: '改为拼手气红包',
        packet: '当前为普通红包,',
        type: '普通红包',
        price: '单个金额'
      })
    }
  },

  //点击获取input总金额
  setPrice: function (e) {
    var userPrice = e.detail.value;
    console.log(userPrice)
    this.setData({
      userPrice,
    })
    if (!userPrice){
      this.setData({
        isPrice:false,
      })
    }else{
      this.setData({
        isPrice: true,
      })
    }
    console.log(this.data.isPrice)
  },

  //点击获取input红包个数
  setNum: function (e) {
    var userNum = e.detail.value;
    console.log(userNum)
    this.setData({
      userNum,
    })
    if (!userNum){
      this.setData({
        isNum:false
      })
    } else {
      this.setData({
        isNum: true,
      })
    }
    console.log(this.data.isNum)
  },
  
  //点击塞钱进红包
  sendPacket:function(){
    var types;
    if (this.data.type == '普通红包'){
      types = 'fix'
    }else{
      types = 'random'
    }
    var userNum = this.data.userNum;
    var totalAmount = this.data.userNum * this.data.userPrice;
    console.log(userNum)
    console.log(totalAmount)
    let param={
      "totalAmount": totalAmount,
      "totalQty": userNum,
      "type": types
    }

    var token = wx.getStorageSync('Token_date') && wx.getStorageSync('Token_date').Token;
    ajaxhelper.post(app.globalData.frontJSHost + "hongbaoPrivate/createHongbaoPrivate?token=" + encodeURIComponent(token), param, this, this.setListData)
  },
  setListData:function(res){
    console.log(res)
  },

  

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    
  },

  
})